package com.atguigu.gmall.mq.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.mq.config.DeadLetterConfig;
import com.atguigu.gmall.mq.config.DelayedMqConfig;
import com.atguigu.gmall.service.RabbitService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 李旭
 * @Time: 14:34
 * @Description:
 *
 * 发消息
 */
@RestController
@RequestMapping("/api/mq")
public class SendMessageController {


    @Autowired
    private RabbitService rabbitService;

    //发消息
    @GetMapping("/sendMessage")
    public Result sendMessage(){
        rabbitService.sendMessage("exhange1","routingKey","小张");
        return Result.ok();
    }
    //发送 基于死信的延迟消息
    @GetMapping("/sendDeadLetterMessage")
    public Result sendDeadLetterMessage(){
        rabbitService.sendDeadLetterMessage(DeadLetterConfig.exchange_dead
          ,DeadLetterConfig.routing_dead_1,"小王",13);
        return Result.ok();
    }
    //发消息  基于插件的延迟消息
    @GetMapping("/sendDelayMessage")
    public Result sendDelayMessage(){
        rabbitService.sendDelayMessage(DelayedMqConfig.exchange_delay,
                DelayedMqConfig.routing_delay,"小八哥",16);
        return Result.ok();
    }
}
